#pragma once


#include "Game.h"
#include "MainMenuState.h"
#include "GameplayState.h"

#include "../wrappers/CSGD_Direct3D.h"
#include "../wrappers/CSGD_DirectInput.h"
#include "../wrappers/CSGD_TextureManager.h"
#include "../wrappers/CSGD_XAudio2.h"

#include "BitmapFont.h"


/* static */ CMainMenuState* CMainMenuState::GetInstance( void )
{
	static CMainMenuState sInstance;
	return &sInstance;
}


CMainMenuState::CMainMenuState(void)
{
	m_pD3D			= nullptr;
	m_pDI			= nullptr;
	m_pTM			= nullptr;
	m_pXA			= nullptr;

	//Assest Ids
	BGimg			= -1;

	currSelection	= 1;

}


CMainMenuState::~CMainMenuState(void)
{
}


void CMainMenuState::Enter( void )
{
	m_pD3D		= CSGD_Direct3D::GetInstance();
	m_pDI		= CSGD_DirectInput::GetInstance();
	m_pTM		= CSGD_TextureManager::GetInstance();
	m_pXA		= CSGD_XAudio2::GetInstance();

	//Assest Ids
	//BGimg		= m_pTM->LoadTexture(_T("../resources/images/TempBG.png"));

}


void CMainMenuState::Exit( void )
{
	//m_pTM->UnloadTexture(BGimg);
	//BGimg = -1;
}


bool CMainMenuState::Input( void )
{
	if( m_pDI->KeyPressed( DIK_RETURN ) )
	{
		if(currSelection == 1 || currSelection == 2)

			CGame::GetInstance()->ChangeState( CGameplayState::GetInstance() );


		if(currSelection == 5)
			return false;
	}

	if(m_pDI->KeyPressed(DIK_UP) )
	{
		currSelection--;
	}

	if(m_pDI->KeyPressed(DIK_DOWN) )
	{
		currSelection++;
	}

	if(m_pDI->KeyPressed(DIK_RIGHT) )
	{
		if(currSelection == 1)
			currSelection = 2;
	}
	if(m_pDI->KeyPressed(DIK_LEFT) )
	{
		if(currSelection == 2)
			currSelection = 1;
	}
	
	

	return true;
}


void CMainMenuState::Update( float fElapsedTime )
{
	if(currSelection <= 0)
		currSelection = 5;
	if(currSelection >= 6)
		currSelection = 1;
}


void CMainMenuState::Render( void )
{
<<<<<<< HEAD
	//if(BGimg != -1)
	//	_pTM->Draw(BGimg,0,0);//,1,1,nullptr, 0,0,0,0)


	m_pD3D->DrawText(_T("ONSLAUGHT"), 350, 100, 255, 0, 0 );
	
	//Save/Load
	if(currSelection == 1)
	{
		m_pD3D->DrawText(_T("New Game"), 250, 200, 255, 255, 255 );
		m_pD3D->DrawText(_T("Load Game"), 450, 200, 255, 100, 100 );
		m_pD3D->DrawText(_T("Options"), 350, 250, 255, 100, 100 );
		m_pD3D->DrawText(_T("Credits"), 350, 300, 255, 100, 100 );
		m_pD3D->DrawText(_T("EXIT"), 360, 350, 255, 100, 100 );
	}
	if(currSelection == 2)
	{
		m_pD3D->DrawText(_T("New Game"), 250, 200, 255, 100, 100 );
		m_pD3D->DrawText(_T("Load Game"), 450, 200, 255, 255, 255 );
		m_pD3D->DrawText(_T("Options"), 350, 250, 255, 100, 100 );
		m_pD3D->DrawText(_T("Credits"), 350, 300, 255, 100, 100 );
		m_pD3D->DrawText(_T("EXIT"), 360, 350, 255, 100, 100 );
	}
	if(currSelection == 3)
	{
		m_pD3D->DrawText(_T("New Game"), 250, 200, 255, 100, 100 );
		m_pD3D->DrawText(_T("Load Game"), 450, 200, 255, 100, 100 );
		m_pD3D->DrawText(_T("Options"), 350, 250, 255, 255, 255 );
		m_pD3D->DrawText(_T("Credits"), 350, 300, 255, 100, 100 );
		m_pD3D->DrawText(_T("EXIT"), 360, 350, 255, 100, 100 );
	}
	if(currSelection == 4)
	{
		m_pD3D->DrawText(_T("New Game"), 250, 200, 255, 100, 100 );
		m_pD3D->DrawText(_T("Load Game"), 450, 200, 255, 100, 100 );
		m_pD3D->DrawText(_T("Options"), 350, 250, 255, 100, 100 );
		m_pD3D->DrawText(_T("Credits"), 350, 300, 255, 255, 255 );
		m_pD3D->DrawText(_T("EXIT"), 360, 350, 255, 100, 100 );
	}
	if(currSelection == 5)
	{
		m_pD3D->DrawText(_T("New Game"), 250, 200, 255, 100, 100 );
		m_pD3D->DrawText(_T("Load Game"), 450, 200, 255, 100, 100 );
		m_pD3D->DrawText(_T("Options"), 350, 250, 255, 100, 100 );
		m_pD3D->DrawText(_T("Credits"), 350, 300, 255, 100, 100 );
		m_pD3D->DrawText(_T("EXIT"), 360, 350, 255, 255, 255 );
	}



=======
	//m_pD3D->DrawText(_T("MainMenuState"), 400, 300, 255, 255, 255 );
	CBitmapFont::GetInstance()->Print( "MainMenuState", 400, 300 );
>>>>>>> d25ca73a95776a515f8a8f89fe1d3f131c5a805e
}
